#ifndef __HWARNINGS_H__
#define __HWARNINGS_H__

//#include <vector>
//#include <string>
#include "HVisitor.h"

struct HWarning {
	// text from source code
	std::string text;
	// warning message
	std::string msg;
	// location
	size_t line_no, pos_in_line;
};

class HWarnings {
private:
	static unsigned int ymr;
	std::vector<HWarning> _warnings;
	/*
	 * When a warning is emitted, we first push it to `_warnings`
	 * with `msg` set but other info not set (not located).
	 * `to_be_located` points to the next warning to be located.
	 * When `locate()` is called, all warnings not located will be
	 * filled with `text` and position. This is usually called
	 * in `visitxxx()` in `HVisitor.c`, because they know the exact
	 * text and location.
	 */
	size_t to_be_located;
public:
	HWarnings();
	const std::vector<HWarning> & warnings() const { return _warnings; }
	const HWarning & warning(size_t i) const { return _warnings.at(i); }
	size_t add_warning(const char *msg);
	size_t locate(antlr4::ParserRuleContext *ctx);
	void show() const;
	~HWarnings();
};

#endif